Skip to content

allow a not_in_domain_value in interpolate!#120

Merged
chmerdon merged 3 commits intomasterfrom
chmerdon/interpolate_notindomainvalue
Apr 15, 2026
Merged

allow a not_in_domain_value in interpolate!#120
chmerdon merged 3 commits intomasterfrom
chmerdon/interpolate_notindomainvalue

Conversation

@chmerdon
Copy link
Copy Markdown
Member

When a grid is interpolated onto a smaller grid, it can happen that the tested node is not in the new domain and the @Assert causes a crash. Instead this PR suggests to set a not_in_domain_value.

Copy link
Copy Markdown
Member

@pjaap pjaap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally like this. Can you cover this by a small test?

For some reason I would prefer to have a failure if no not_in_domain_value is set.
How about the default nothing and keep the @assert in this case? The NaN default may lead to hard to catch errors.

@chmerdon
Copy link
Copy Markdown
Member Author

I can think about a test. But I would like to remove the @Assert for the UnicodePlots extension. Here I need to interpolate on a rectangular grid that is possibly larger than the original grid. If I don't remove the assert this would crash. But maybe we can offer a boolean check_if_not_in_domain instead of not_in_domain_value and then set NaN if the check fails?

@pjaap
Copy link
Copy Markdown
Member

pjaap commented Apr 14, 2026

Ideally, we have both check_if_not_in_domain = true and not_in_domain_value = NaN kwargs.

My suggestion aimed at using internally check_if_not_in_domain = isnothing(not_in_domain_value). But having both explicit switches may be the best solution?

@chmerdon
Copy link
Copy Markdown
Member Author

Ah, ok if they are set in that way, I think the check does not need to be a kwarg, since anyone who sets a different not_in_domain_values also wants it to be used. But it also would not hurt to have both as a kwarg.

@pjaap pjaap force-pushed the chmerdon/interpolate_notindomainvalue branch from 0003b6f to 7f0f37f Compare April 15, 2026 12:09
@pjaap
Copy link
Copy Markdown
Member

pjaap commented Apr 15, 2026

Rebased and ready to be merged.

@chmerdon chmerdon merged commit ac46d1d into master Apr 15, 2026
12 checks passed
@pjaap pjaap deleted the chmerdon/interpolate_notindomainvalue branch April 15, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants